<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <script>
        let str = "abscjeyxbqaAYIFHOOOlsaaaYYIatgatagaAYGARYFVUI";

        let res = Array.from(str.toLowerCase()).filter((i) => i == "a").length;
        console.log(res);
        //得到某一个字符出现的次数

        // var str1 = "asasDFGHadDfFFhjkMNJGBHGDsdfghjfghjkdfghjkl";
        var str1 = str.toLocaleLowerCase(); //大写字母变小写
        var obj = {};
        for (var i = 0; i < str1.length; i++) {
            var key = str1[i];
            if (obj[key]) {
                obj[key]++;
            } else {
                obj[key] = 1;
            }
        }
        console.log(obj);
        for (var key in obj) {
            console.log(key + "出现" + obj[key] + "次");
        }
        //得到每一个字符出现的次数

        // 3. 将一串含有大、 小写字母的字符串中的大写字母删除
        //   let reg = new RegExp("[A - Z]");
        let res1 = Array.from(str);
        // res1.forEach((i, index) => {
        //     // console.log(reg.test(i));
        //     // if (reg.test(i)) {
        //     //     console.log(i);
        //     //     res1.splice(index, 1);
        //     // }
        //     let num = i.charCodeAt();
        //     console.log(num);
        //     if (num >= 65 && num <= 90) {
        //         res1.splice(index, 1);
        //     }
        // });

        for (let i = 0; i < res1.length; i++) {
            let num = res1[i].charCodeAt();
            console.log(num);
            if (num >= 65 && num <= 90) {
                res1.splice(i, 1);
                i--;
                //删除一个让i--
            }
        }
        console.log(res1);
        //删除 大写字符 用正则或者ASICC编码
    </script>
</body>

</html>